using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

using GURUCORE.Framework.Core.Util.Localization;
using GURUCORE.Framework.Core.Util.Customization;

namespace GURUCORE.Portal.AspNet.Control.Localized
{
	
	public class LocalizedImage : Image, IThemable
	{
		string m_sTheme;

		public string Theme
		{
			get
			{
				return m_sTheme;
			}
			set
			{
				m_sTheme = value;
			}
		}

		protected override void Render(HtmlTextWriter writer) 
		{
			if (HttpContext.Current != null)
			{
				System.Web.UI.Control ctlNamingContainer = this.NamingContainer;
				if (ctlNamingContainer == null)
				{
					base.Render(writer);
					return;
				};
				while (!(ctlNamingContainer is UserControl || ctlNamingContainer is Page))
				{
					ctlNamingContainer = ctlNamingContainer.NamingContainer;
					if (ctlNamingContainer == null)
					{
						base.Render(writer);
						return;
					};
				}

				string sImageURL = ResourceManager.GetString(ctlNamingContainer.GetType().BaseType.FullName, this.ID);

				if (sImageURL != string.Empty)
				{
					base.ImageUrl = sImageURL;
				}
			}
			base.Render(writer);
		}
	}
}
